package bsea.jan21;

import java.sql.SQLException;

public class UserService {
	public boolean login(String username,String pwd) throws SQLException{
		boolean result=false;
		UserDao ud=new UserDao();
		User u=ud.getUserbyName(username);
		if(pwd.equals(u.getPwd())){
			result=true;
		}
		return  result;
	}
	public boolean register(User u) throws SQLException{
		boolean flag=false;
		System.out.println("register name"+u.getUserName());
		UserDao ud=new UserDao();
		User u2=ud.getUserbyName(u.getUserName());
		System.out.println("name2="+u2.getPwd());
		if((u2.getPwd()=="")&&ud.addUser(u)){
			flag=true;
		}
		return flag;
		
	}

}
